package Network.homework;

import java.io.IOException;
import java.util.HashMap;

public class TcpDirectServer extends TcpEchoServer{
    private HashMap<String,String> hashMap=new HashMap<>();
    public TcpDirectServer(int port) throws IOException {
        super(port);
        hashMap.put("cat","小猫");
        hashMap.put("dog","小狗");
        hashMap.put("pig","小猪");
        hashMap.put("flag","小鸟");
    }

    @Override
    public String process(String request) {
        return hashMap.getOrDefault(request,"要查的单词不存在");
    }

    public static void main(String[] args) throws IOException {
        TcpDirectServer tcpDirectServer = new TcpDirectServer(9090);
        tcpDirectServer.start();
    }
}
